#define _CRT_SECURE_NO_WARNINGS 1
#include"list.h"
void slistprint(List* p) {
	List* one = p;
	while (one != NULL)
	{
		printf("%d->", one->data);
		one = one->next;
	}
	printf("NULL"); 
}


void pushback(List** p, Datay a)
{	List* newnode = (List*)malloc(sizeof(List));
    newnode->data = a;
	newnode->next = NULL;
	if (*p == NULL)
	{
		*p = newnode;
	}
	else 
	{
		List* one = *p;

		while (one->next != NULL)
		{
			one = one->next;
		}
	    one->next = newnode;
	}
	
	
}
void pushfront(List** p, Datay a)
{
	List* newnode = (List*)malloc(sizeof(List));
	newnode->data = a;
	newnode->next = *p;
	*p = newnode;
}

void popfront(List** p)
{
	if (*p == NULL)
	{
		return;
	}
	List* w = (*p)->next;
	free(*p);
	*p = w;;
}
void popback(List** p)
{
	
	if ((*p)->next == NULL)
	{
		free(*p);
		*p = NULL;
	}
	List* w = *p;
	while (w->next->next != NULL)
	{
		w = w->next;
	}
	free(w->next);
	w->next = NULL;
}